package com.novax.ex.activity.provider.service;

import com.novax.ex.activity.infrastructure.entity.OperationV2SubConfig;
import com.novax.ex.activity.infrastructure.mapper.OperationV2SubConfigMapper;
import com.novax.ex.common.base.BaseMapper;
import com.novax.ex.common.base.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * @Description 活动落地页配置V2 子配置
 * @Author ChenXi
 * @Date 2023/04/18/10:08
 */

@Service
public class OperationV2SubConfigService extends BaseService {

    @Resource
    private OperationV2SubConfigMapper operationV2SubConfigMapper;

    @Override
    protected BaseMapper getBaseMapper() {
        return operationV2SubConfigMapper;
    }

    /**
     * @Description: 查询所有子配置
     * @Author: ChenXi
     * @Date:  2024/4/25 16:18
     * @param operationId
     * @return: com.novax.ex.activity.infrastructure.entity.OperationV2SubConfig
     **/
    public List<OperationV2SubConfig> list(Long operationId) {
        return operationV2SubConfigMapper.list(operationId);
    }

    /**
     * @Description: 批量删除
     * @Author: ChenXi
     * @Date:  2024/4/26 11:02
     * @param ids
     * @return: boolean
     **/
    @Transactional(rollbackFor = RuntimeException.class)
    public boolean batchRemove(String ids) {
        String[] idArr = ids.split(",");
        if (idArr.length > 0) {
            return operationV2SubConfigMapper.batchRemove(idArr) > 0;
        }
        return true;
    }

    /**
     * @Description: 查询开启的子活动
     * @Author: ChenXi
     * @Date:  2024/5/8 11:03
     * @param operationId
     * @return: java.util.List<com.novax.ex.activity.infrastructure.entity.OperationV2SubConfig>
     **/
    public List<OperationV2SubConfig> queryOpenList(Long operationId) {
        return operationV2SubConfigMapper.queryOpenList(operationId);
    }

}
